package com.bryantkobe.myspringcode.exception;

import java.io.Serial;

/**
 * @description: 数据访问异常
 * @author: alienwarezzl
 * @date: 2025/9/22
 */
public final class DataAccessException extends BusinessException implements BusinessExceptionType{
    @Serial
    private static final long serialVersionUID = 1L;

    private final String operation;
    private final String entityType;

    public DataAccessException(String operation, String entityType, String message, Throwable cause) {
        super("DATA_ACCESS_ERROR", message, cause,null);
        this.operation = operation;
        this.entityType = entityType;
        withParam("operation", operation)
                .withParam("entityType", entityType);
    }

    @Override
    public String getCategory() {
        return "DATA_ACCESS";
    }

    public String getOperation() {
        return operation;
    }

    public String getEntityType() {
        return entityType;
    }
}
